// import log from '@dfeidao/atom-nodejs/logger/log';
import query from '@dfeidao/atom-nodejs/db/query';

import { systemid, productid } from '../atom/config';

interface Message {
	filter: {
		[key: string]: string
	};
	page_no: number;
}


interface IGoodsCategory {	// // 商品类别goods_category
	category_num: string;	// 类别编号
	category_name: string;	// 类别名称
	superior_category_number: string;	// 上级类别编号
	level: string;	// 层级
	fzno: string;	// 顺序号
	is_stop: number;	// 是否停用（是1、否0）
	memo: string;	// 备注
}


export default async function atom(msg: Message, action_id: string, session_id: string) {
	const asc = ['fzno'];

	const { exec, prepare } = query(action_id, session_id, systemid);
	prepare('goods_category', ['category_num', 'category_name', 'superior_category_number', 'level'], { ...msg.filter, productid }, 200, 1, asc, []);
	const [goods] = await exec<IGoodsCategory>();
	return goods;
}
